#ifndef _BG_EDITOR_H_
#define _BG_EDITOR_H_

#include "editor/editor_main.h"
#include "editor/editor_brush.h"

namespace LuaPlus
{
	class LuaState;	
}
namespace background
{
class BGScene;
class BGElement;
class BGPath;
class ElementBrush : public editor::EditorBrush
{
public:
	ElementBrush(editor::EditorMain* pEditor) ;
	
   	virtual ~ElementBrush ();
	virtual void	Tick(float dt);
	virtual bool	TryDelete(const math::Vec2& Pos);
	virtual void	SetPos(const math::Vec2& Pos) ;
	virtual void	UpdateElement();
	virtual void	SetElement(const std::string Name);
	virtual void	AddElement(BGElement* pEl);
	virtual void	Render(const math::Vec2& Offset, float Scale);
	virtual void	OnEnter();
	virtual void	ReleaseLMB();
	virtual void	Rotate(int Dir);
	virtual void	RotateGrid(int Dir);
	virtual void	Raise(int Dir);
	virtual bool	ShowAnimation() { return false; };
	virtual bool	IsMoving()  { return false; };
protected:
	BGPath*			GetSpline(const math::Vec2& P);
	BGElement*			m_pElement;
	float				m_Rotation;
	float				m_SortVal;

	math::Vec2			m_LastPos;
	math::Vec2			m_OrigPos;
	math::Vec2			m_Dir;
	bool				m_GetDirection;
};


class BGEditor : public editor::EditorMain
{
public:
	static BGEditor*			s_pBGEditor;

								BGEditor(BGScene* pScene);
								~BGEditor();
	virtual void				Init();
	virtual void				Shutdown();

	BGScene*					GetScene() const { return m_pScene; }
	static void					RegisterDecalSet(const std::string& Decals);
private:
	virtual bool				CustomDelete(const math::Vec2& Pos);
	BGScene*					m_pScene;
};

};	//namespace background

#endif // _BG_EDITOR_H_